home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / faq < prev    next >
Text File  |  1999-04-19  |  8KB  |  216 lines

  1. FAQ (Frequently Asked Questions and answers) for SLIB Scheme Library (slib2c5).
  2. Written by Aubrey Jaffer (http://swissnet.ai.mit.edu/~jaffer).
  3.  
  4.         INTRODUCTION AND GENERAL INFORMATION
  5.  
  6. []    What is SLIB?
  7.  
  8. SLIB is a portable scheme library meant to provide compatibiliy and
  9. utility functions for all standard scheme implementations.
  10.  
  11. []    What is Scheme?
  12.  
  13. Scheme is a programming language in the Lisp family.
  14.  
  15. []    Which implementations has SLIB been ported to?
  16.  
  17. SLIB is supported by Chez, ELK 2.1, GAMBIT, MacScheme, MITScheme,
  18. scheme->C, Scheme48, T3.1, SCM and VSCM
  19.  
  20. []    How can I obtain SLIB?
  21.  
  22. SLIB is available via ftp from:
  23.  swissnet.ai.mit.edu:pub/scm/slib2c5.tar.gz
  24.  prep.ai.mit.edu:pub/gnu/jacal/slib2c5.tar.gz
  25.  
  26. SLIB is also included with SCM floppy disks.
  27.  
  28. []    How do I install SLIB?
  29.  
  30. Read the INSTALLATION INSTRUCTIONS in "slib/README".
  31.  
  32. []    What are slib.texi and slib.info?
  33.  
  34. "slib.texi" is the `texinfo' format documentation for SLIB.
  35. "slib.info" is produced from "slib.texi" by either Gnu Emacs or the
  36. program `makeinfo'.  "slib.info" can be viewed using either Gnu Emacs
  37. or `info' or a text editor.
  38.  
  39. Programs for printing and viewing TexInfo documentation (which SLIB
  40. has) come with GNU Emacs or can be obtained via ftp from:
  41. prep.ai.mit.edu:pub/gnu/texinfo-3.1.tar.gz
  42.  
  43. []    How often is SLIB released?
  44.  
  45. Several times a year.
  46.  
  47. []    What is the latest version?
  48.  
  49. The version as of this writing is slib2c5.  The latest documentation
  50. is available online at:
  51.  http://swissnet.ai.mit.edu/~jaffer/SLIB.html
  52.  
  53. []    Which version am I using?
  54.  
  55. The Version is in the first line of the files slib/FAQ, slib/ANNOUNCE,
  56. and slib/README.  If you have Scheme and SLIB running, type
  57. (slib:report-version)
  58.  
  59.         SLIB INSTALLATION PROBLEMS
  60.  
  61. []    When I load an SLIB initialization file for my Scheme
  62.     implementation, I get ERROR: Couldn't find "require.scm"
  63.  
  64. Did you remember to set either the environment variable
  65. SCHEME_LIBRARY_PATH or the library-vicinity in your initialization
  66. file to the correct location?  If you set SCHEME_LIBRARY_PATH, make
  67. sure that the Scheme implementation supports getenv.
  68.  
  69. []    When I load an SLIB initialization file for my Scheme
  70.     implementation, I get ERROR: Couldn't find
  71.     "/usr/local/lib/slibrequire.scm"
  72.  
  73. Notice that it is looking for "slibrequire.scm" rather than
  74. "slib/require.scm".  You need to put a trailing slash on either the
  75. environment variable SCHEME_LIBRARY_PATH or in the library-vicinity in
  76. your initialization file.
  77.  
  78. []    SLIB used to work, but now I get ERROR: Couldn't find
  79.     "slib/require.scm".  What happened?
  80.  
  81. You changed directories and now the relative pathname
  82. "slib/require.scm" no longer refers to the same directory.  The
  83. environment variable SCHEME_LIBRARY_PATH and library-vicinity in your
  84. initialization file should be absolute pathnames.
  85.  
  86. []    When I type (require 'macro) I get "ERROR: unbound variable:
  87.     require".
  88.  
  89. You need to arrange to have your Scheme implementation load the
  90. appropriate SLIB initialization file ("foo.init") before using SLIB.
  91. If your implementation loads an initialization file on startup, you
  92. can have it load the SLIB initialization file automatically.  For
  93. example (load "/usr/local/lib/slib/foo.init").
  94.  
  95. []    Why do I get a string-ref (or other) error when I try to load
  96.     or use SLIB.
  97.  
  98. Check that the version of the Scheme implementation you are using
  99. matches the version for which the SLIB initialization file was
  100. written.  There are some notes in the SLIB initialization files about
  101. earlier versions.  You may need to get a more recent version of your
  102. Scheme implementation.
  103.  
  104.         USING SLIB PROCEDURES
  105.  
  106. []    I installed SLIB.  When I type (random 5) I get "ERROR:
  107.     unbound variable:  random".  Doesn't SLIB have a `random'
  108.     function?
  109.  
  110. Before you can use most SLIB functions, the associated module needs to
  111. be loaded.  You do this by typing the line that appears at the top of
  112. the page in slib.info (or slib.texi) where the function is documented.
  113. In the case of random, that line is (require 'random).
  114.  
  115. []    Why doesn't SLIB just load all the functions so I don't have
  116.     to type require statements?
  117.  
  118. SLIB has more than 1 Megabyte of Scheme source code.  Many scheme
  119. implementations take unacceptably long to load 1 Megabyte of source;
  120. some implementations cannot allocate enough storage.  If you use a
  121. package often, you can put the require statement in your Scheme
  122. initialization file.  Consult the manual for your Scheme
  123. implementation to find out the initialization file's name.
  124.  
  125. `Autoloads' will work with many Scheme implementations.  You could put
  126. the following in your initialization file:
  127.  (define (random . args) (require 'random) (apply random args))
  128.  
  129. I find that I only type require statements at top level when
  130. debugging.  I put require statements in my Scheme files so that the
  131. appropriate modules are loaded automatically.
  132.  
  133. []    Why does SLIB have PRINTF when it already has the more
  134.     powerful (CommonLisp) FORMAT?
  135.  
  136. CommonLisp FORMAT does not support essential features which PRINTF
  137. does.  For instance, how do you format a signed 0 extended number?
  138.  
  139.   (format t "~8,'0,X~%" -3)    ==>    000000-3
  140.  
  141. But printf gets it right:
  142.  
  143.   (printf "%08x\n" -3)        ==>    -0000003
  144.  
  145. How can one trunctate a non-numeric field using FORMAT?  This feature
  146. is essential for printing reports.  The first 20 letters of a name is
  147. sufficient to identify it.  But if that name doesn't get trucated to
  148. the desired length it can displace other fields off the page.  Once
  149. again, printf gets it right:
  150.  
  151.   (printf "%.20s\n" "the quick brown fox jumped over the lazy dog")
  152.                 ==>    the quick brown fox
  153.  
  154. FORMAT also lacks directives for formatting date and time.  printf
  155. does not handle these directly, but a related function strftime does.
  156.  
  157. []    Why doesn't SLIB:ERROR call FORMAT?
  158.  
  159. Format does not provide a method to truncate fields.  When an error
  160. message contains non-terminating or large expressions, the essential
  161. information of the message may be lost in the ensuing deluge.
  162.  
  163. FORMAT as currently written in SLIB is not reentrant.  Until this is
  164. fixed, exception handlers and errors which might occur while using
  165. FORMAT cannot use it.
  166.  
  167.         MACROS
  168.  
  169. []    Why are there so many macro implementations in SLIB?
  170.  
  171. The R4RS committee specified only the high level pattern language in
  172. the Revised^4 Report on Scheme and left to the free marketplace of
  173. ideas the details of the low-level facility.  Each macro package has a
  174. different low-level facility.  The low-level facilities are sometimes
  175. needed because the high level pattern language is insufficiently
  176. powerful to accomplish tasks macros are often written to do.
  177.  
  178. []    Why are there both R4RS macros and Common-Lisp style defmacros
  179.     in SLIB?
  180.  
  181. Most Scheme implementations predate the adoption of the R4RS macro
  182. specification.  All of the implementations except scheme48 version
  183. 0.45 support defmacro natively.
  184.  
  185. []    I did (LOAD "slib/yasos.scm").  The error I get is "variable
  186.     define-syntax is undefined".
  187.  
  188. The way to load the struct macro package is (REQUIRE 'YASOS).
  189.  
  190. []    I did (REQUIRE 'YASOS).  Now when I type (DEFINE-PREDICATE
  191.     CELL?)  The error I get is "variable define-predicate is
  192.     undefined".
  193.  
  194. If your Scheme does not natively support R4RS macros, you will need to
  195. install a macro-capable read-eval-print loop.  This is done by:
  196.  (require 'macro)    ;already done if you did (require 'yasos)
  197.  (require 'repl)
  198.  (repl:top-level macro:eval)
  199.  
  200. This would also be true for a Scheme implementation which didn't
  201. support DEFMACRO.  The lines in this case would be:
  202.  (require 'repl)
  203.  (repl:top-level defmacro:eval)
  204.  
  205. []    I always use R4RS macros with an implementation which doesn't
  206.     natively support them.  How can I avoid having to type require
  207.     statements every time I start Scheme?
  208.  
  209. As explained in the Repl entry in slib.info (or slib.texi):
  210.  
  211.  To have your top level loop always use macros, add any interrupt
  212.  catching code and the following script to your Scheme init file:
  213.   (require 'macro)
  214.   (require 'repl)
  215.   (repl:top-level macro:eval)
  216.